package com.daybyday.day1.day2;

import javax.sound.midi.Soundbank;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Queue;

/*
@李子宁
Happy,happy everyday!
冲鸭！
2020/10/15

*/
class Solution {

    public static void main(String[] args) {
        String a = "abcde";
        String b = "cdeab";
        Solution s = new Solution();
        s.rotateString(a, b);
        System.out.println(s.rotateString(a, b));
    }
    public boolean rotateString(String A, String B) {
        char[] a = A.toCharArray();
        int move = 0;
        ArrayList<Character> list = new ArrayList<>();
        for(Character c : a){
           list.add(c);
        }
        while(move <= a.length){
            String s = queueToString(list);
            if(queueToString(list).equals(B)){
                return true;
            }else{
                char remove = list.remove(0);
                list.add(remove);
                move ++;
            }
        }
        return false;

    }

    public String queueToString(ArrayList<Character> queue){
        StringBuilder sb = new StringBuilder();
        for (Character character : queue) {
            sb.append(character);
        }

        return sb.toString();
    }
}